import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-09-24
 * 14:34
 */
public class Main {
    public static void main(String[] args) {
        List<Integer> list=new ArrayList<>();

        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = in.nextInt();
            int count=0;
            for(int j=a;j<=b;j++){
                if(j==20||j==200||j==2000){
                    count++;
                    continue;
                }
                if(j==2){
                    count++;
                }
                int ret=j;
                while(j>10){
                    if(j%10==2){
                        count++;
                    }
                    j=j/10;
                    if(j==2){
                        count++;
                    }
                }
                j=ret;

            }
            System.out.println(count);

        }
    }
}